package com.apexedu.identity.entity;

import javax.persistence.*;
import java.util.Date;

/**
 * TSysUser entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name = "T_SYS_USER")
public class TSysUser implements java.io.Serializable {

	/**
	 * 希望类的不同版本对序列化兼容，只要确保类的不同版本具有相同的serialVersionUID
	 */
	private static final long serialVersionUID = 1L;

	private String userid;
	private String userloginid;
	private String username;
	private String userpwd;
//	private String userdepart;
	private String state;
	private String usertype;
	private Date lastlogintime;//上次登录时间
	private Long logintimes;//登录次数
	private String lastloginip;//上次登录IP

	private TSysDepart depart = null;

	private String userdepart;//非持久化变量，店铺编号
	// Constructors

    private String yhlx; //用户类型
    private String orname; //组织机构
	private String sfzh; //用户类型

	/** default constructor */
	public TSysUser() {
	}

	/** minimal constructor */
	public TSysUser(String userid) {
		this.userid = userid;
	}
	public TSysUser(String userid, String userloginid, String username, String state) {
		super();
		this.userid = userid;
		this.userloginid = userloginid;
		this.username = username;
		this.state = state;
	}

	public TSysUser(String userid, String userloginid, String username, String state, String departname) {
		super();
		this.userid = userid;
		this.userloginid = userloginid;
		this.username = username;
		this.state = state;
		if(depart==null){
			depart = new TSysDepart();
		}
		this.depart.setDepartname(departname);
	}

	/** full constructor */
	public TSysUser(String userid, String userloginid, String username, String state, String departname,
                    String usertype, Date lastlogintime, Long logintimes, String lastloginip) {
		super();
		this.userid = userid;
		this.userloginid = userloginid;
		this.username = username;
		if(depart==null){
			depart = new TSysDepart();
		}
		this.depart.setDepartname(departname);
		this.state = state;
		this.usertype = usertype;
		this.lastlogintime = lastlogintime;
		this.logintimes = logintimes;
		this.lastloginip = lastloginip;
	}
	// Property accessors
	@Id
	@Column(name = "USERID", unique = true, nullable = false, length = 50)
	public String getUserid() {
		return this.userid;
	}

	public void setUserid(String userid) {
		this.userid = userid;
	}

	@Column(name = "USERLOGINID", unique = true, length = 50)
	public String getUserloginid() {
		return this.userloginid;
	}

	public void setUserloginid(String userloginid) {
		this.userloginid = userloginid;
	}

	@Column(name = "USERNAME", length = 200)
	public String getUsername() {
		return this.username;
	}

	public void setUsername(String username) {
		this.username = username;
	}

	@Column(name = "USERPWD", length = 100)
	public String getUserpwd() {
		return this.userpwd;
	}

	public void setUserpwd(String userpwd) {
		this.userpwd = userpwd;
	}

	@Column(name = "STATE", length = 3)
	public String getState() {
		return this.state;
	}

	public void setState(String state) {
		this.state = state;
	}

	@Column(name = "USERTYPE", length = 3)
	public String getUsertype() {
		return this.usertype;
	}

	public void setUsertype(String usertype) {
		this.usertype = usertype;
	}

	@ManyToOne (optional=true, cascade = { CascadeType.REFRESH}, fetch = FetchType.EAGER, targetEntity=TSysDepart.class)   
	@JoinColumn(name="userdepart", nullable=true)
	public TSysDepart getDepart() {
		return depart;
	}

	public void setDepart(TSysDepart depart) {
		this.depart = depart;
	}


	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "LASTLOGINTIME", length = 7)
	public Date getLastlogintime() {
		return lastlogintime;
	}

	public void setLastlogintime(Date lastlogintime) {
		this.lastlogintime = lastlogintime;
	}

	@Column(name = "LOGINTIMES", precision = 10, scale = 0)
	public Long getLogintimes() {
		return logintimes;
	}

	public void setLogintimes(Long logintimes) {
		this.logintimes = logintimes;
	}

	@Column(name = "LASTLOGINIP", length = 50)
	public String getLastloginip() {
		return lastloginip;
	}

	public void setLastloginip(String lastloginip) {
		this.lastloginip = lastloginip;
	}
    
	@Transient
	public String getUserdepart() {
		return userdepart;
	}

	public void setUserdepart(String userdepart) {
		this.userdepart = userdepart;
	}

    @Transient
    public String getYhlx() {
        return yhlx;
    }

    public void setYhlx(String yhlx) {
        this.yhlx = yhlx;
    }

    @Transient
    public String getOrname() {
        return orname;
    }

    public void setOrname(String orname) {
        this.orname = orname;
    }

	@Transient
	public String getSfzh() {
		return sfzh;
	}

	public void setSfzh(String sfzh) {
		this.sfzh = sfzh;
	}
}